from datetime import datetime
from pydantic import BaseModel, Field

from app.utils.tool import to_lower_camel


class CouponOutSchema(BaseModel):
    id: int = Field(..., description='自增ID')
    name: str = Field(..., max_length=32, description='优惠券名称')
    discount_amount: int = Field(..., description='优惠券金额')
    cate_id: int = Field(..., description='优惠券分类ID')
    cate_name: str = Field(..., description='优惠券分类名称')
    min_amount: float = Field(..., description='满减金额')
    total_num: int = Field(..., description='总数量')
    get_num: int = Field(default=0, description='领取数量')
    use_num: int = Field(default=0, description='使用数量')
    status: int = Field(1, description='优惠券状态')
    limit_get_num: int = Field(..., description='领取数量')
    bind_client_phone: int = Field(..., description='是否绑定领取手机号')
    use_rule_id: int = Field(..., description='使用条件ID')
    valid_days: int = Field(..., description='有效期天数')
    start_time: datetime = Field(..., description='创建时间')
    end_time: datetime = Field(..., description='过期时间')
    goods_ids: str | None = Field(..., max_length=255, description='优惠券商品ID')
    goods_cate_ids: str | None = Field(...,
                                       max_length=255, description='优惠券商品分类ID')
    sort: int = Field(default=1, description='优惠券排序')
    description: str | None = Field(..., max_length=255, description='优惠券描述')

    model_config = {
        "alias_generator": to_lower_camel,
        "populate_by_name": True,
        "from_attributes": True,
    }
